/*
 * lib.h
 *
 *  Created on: 2010.06.26
 *      Author: Tadas
 */

#ifndef LIB_H_
#define LIB_H_

#define MULT 1103515245
#define INC 12345

#define MULTI 16807
#define RMAX 2147483647
#define IRMAX (1.0/RMAX)
#define QI 127773
#define WI 2836
#define MASK 123459876

long seed = 5;

int randBl(){
	int temp;
	seed = MULT * seed + INC;
	
	temp = (int)(seed >> 16);
	
	return (temp & 0x7FFF);
}


float randGe(){
	long k;
	float ans;
	seed ^= MASK;
	k = seed/QI;
	
	seed = MULTI * (seed - k * QI) - WI*k;
	if(seed < 0){
		seed += RMAX;	
	}
	
	ans = IRMAX * seed;
	
	seed ^= MASK;
	
	return ans;	
}


#endif /* LIB_H_ */
